package com.dc.trans.steps.customperform;

import org.pentaho.di.core.row.RowDataUtil;
import org.pentaho.di.core.row.RowMetaInterface;
import org.pentaho.di.core.row.ValueMeta;
import org.pentaho.di.core.row.ValueMetaInterface;



public class CustomexecuterImpl implements Customexecuter {

	private Custome cus;
	private int oldRowMetaSize = -1;
	private String addField="c";
	private RowMetaInterface newputRowMeta;
	@Override
	public Custome execute(RowMetaInterface inputRowMeta,CustomperformMeta meadate,Object[] r) throws Exception {
		// TODO Auto-generated method stub
		cus=new Custome();
		newputRowMeta=inputRowMeta.clone();
		ValueMetaInterface valueMeta1=new ValueMeta(addField, ValueMeta.TYPE_STRING); // build a value!
		valueMeta1.setLength(-1);
		valueMeta1.setPrecision(-1);
		valueMeta1.setOrigin(meadate.getName());
		oldRowMetaSize = inputRowMeta.getValueMetaList().size();			
		newputRowMeta.addValueMeta(oldRowMetaSize, valueMeta1);
		
		Object[] newRowData = RowDataUtil.allocateRowData(r.length+1);
		for(int h=0;h<r.length;h++){
			newRowData[h] = r[h];
		}
		newRowData[oldRowMetaSize]="3333";
		cus.setOutputRowMeta(newputRowMeta);
		cus.setNewRowData(newRowData);
		return cus;
	}

}
